<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
<style>

  .box{
    position: absolute;
    width: 300px;
    height: 300px;
    background-color: greenyellow;
    left: 50%;
    top: 50px;
    margin-left: -150px;
  }
  .box2{
    position: absolute;
    width: 300px;
    height: 300px;
    background-color: goldenrod;
    left: 50%;
    top: 50px;
    margin-left: -150px;
  }
  .fade-enter{
    transform: translateX(-500px) scale(.2);
    opacity: 0;
  }
  .fade-leave-to{
    transform: translateX(500px) scale(.2);
    opacity: 0;
  }
  .fade-enter-active,
  .fade-leave-active{
    transition: all .5s;
  }
</style>
</head>
<body>

  <div id='app'>
    <button @click="isShow = !isShow">{{isShow?'消失':'显示'}}</button>
    <transition name="fade">
      <div class="box" v-if="isShow" key="1"></div>
      <div class="box2" v-else key="2"></div>
    </transition>
  </div>

<script src='https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js'></script>
<script>
  const app = new Vue({
    el: '#app'
    ,data: {
      msg: 'Hello Vue'
      ,isShow: false
    }
    ,methods: {
      
    }
  })
</script>
</body>
</html>